<html>
<head>
<title>GW-BASIC User's Guide</title>
<link rel="stylesheet" href="stylesheet.css">
</head>

<body>

<h1>INPUT$ Function</h1>
<h4>Purpose:</h4>
<p>To return a string of <span class="code"><i>x</i></span> characters read from the keyboard, or from file number.</p>
<h4>Syntax:</h4>
<pre><b>INPUT$</b>(<i>x</i>[,[<b>#</b>]<i>file number</i>)]</pre>
<h4>Comments:</h4>
<p>If the keyboard is used for input, no characters will appear on the screen. All control characters (except <span class="smallcaps">CTRL-BREAK</span>) are passed through. <span class="smallcaps">CTRL-BREAK</span> interrupts the execution of the <span class="code">INPUT$</span> function.</p>
<p>The <span class="code">INPUT$</span> function is preferred over <span class="code">INPUT</span> and <span class="code">LINE INPUT</span> statements for reading communications files, because all ASCII characters may be significant in communications. <span class="code">INPUT</span> is the least desirable because input stops when a comma or carriage return is seen. <span class="code">LINE INPUT</span> terminates when a carriage return is seen.</p>
<p><span class="code">INPUT$</span> allows all characters read to be assigned to a string. <span class="code">INPUT$</span> will return <i>x </i>characters from the file number or keyboard.</p>
<p>For more information about communications, refer to <a href="Appendix F.html">Appendix F in the GW-BASIC User's Guide</a>.</p>
<h4>Example 1:</h4>
<p>The following example lists the contents of a sequential file in hexadecimal.</p>
<pre>10 OPEN&quot;I&quot;, 1, &quot;DATA&quot;
20 IF EOF(1) THEN 50
30 PRINT HEX$(ASC(INPUT$(1, #1)));
40 GOTO 20
50 PRINT
60 END</pre>
<h4>Example 2:</h4>
<p>In the following program, the program pauses, awaiting a keyboard entry of either P or S. Line 130 continues to loop back to line 100 if the input is other than P or S.</p>
<pre>.
.
.
100 PRINT &quot;TYPE P TO PROCEED OR S TO STOP&quot;
110 X$=INPUT$(1)
120 IF X$=&quot;P&quot; THEN 500
130 IF X$=&quot;S&quot; THEN 700 ELSE 100
.
.
.</pre>
</body>
</html>